# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: jaewon

import datetime

from coin.exchange.okex.kr_rest.currency import OkexCurrency
from coin.exchange.okex.order_gateway import OkexOrderGateway
from coin.exchange.okex_v3.order_gateway import OkexOrderGateway as OkexOrderGatewayV3
from coin.strategy.mm.subscription import SubscriptionRequest
from coin.strategy.mm.base.order_subsystem import BaseOrderSubsystem


class OkexOrderSubsystem(BaseOrderSubsystem):
  OrderGateway = OkexOrderGateway
  OrderSubReq = SubscriptionRequest('Spot', 'Okex', None)
  _delay_notify_order_gateway_reset = datetime.timedelta(seconds=5)

  def __init__(self, *args, subscribe_okdk=False, **kwargs):
    super().__init__(*args, **kwargs)
    if subscribe_okdk:
      self._currencies.append(OkexCurrency.FromStrCurrency('OKDK'))


class OkexOrderSubsystemV3(BaseOrderSubsystem):
  OrderGateway = OkexOrderGatewayV3
  OrderSubReq = SubscriptionRequest('Spot', 'Okex', 'v3')
  _delay_notify_order_gateway_reset = datetime.timedelta(seconds=5)

  def __init__(self, *args, subscribe_okdk=False, **kwargs):
    super().__init__(*args, **kwargs)
    if subscribe_okdk:
      self._currencies.append(OkexCurrency.FromStrCurrency('OKDK'))
